package org.bit.practice01;

/**
 * 多线程编程：顺序打印
 */
public class Demo06_page_order {
    public static void main(String[] args) {
        // 创建 3 个线程
        Thread tc = new Thread(() -> {
            // 打印 c
            System.out.println(Thread.currentThread().getName() + " ");
        }, "c");

        Thread tb = new Thread(() -> {
            try {
                // 等待 c 执行完成
                tc.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }// 打印 b
            System.out.println(Thread.currentThread().getName() + " ");
        }, "b");

        Thread ta = new Thread(() -> {
            // 等待 b 执行完成
            try {
                tb.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(Thread.currentThread().getName() + " ");
        }, "a");

        // 同时启动
        ta.start();
        tb.start();
        tc.start();
    }
}
